#
import glob
import os
import re

try:
    import setuptools
    (setuptools) # for pyflakes
except ImportError:
    from distribute_setup import use_setuptools
    use_setuptools()

from setuptools import setup, find_packages


VERRX = re.compile(r'((\d+\.)+\d)\.txt$')

def versionFromReleaseNotes():
    """
    Indomnify's official version is the latest version of the release notes found
    in doc/release-notes.
    """
    thisDir = os.path.abspath(__file__).rsplit(os.sep, 1)[0]
    if thisDir == __file__:
        thisDir = ''

    versions = glob.glob(os.sep.join(
        [thisDir, 'doc', 'release-notes', '[0-9]*.txt']))
    if versions:
        return VERRX.search(max(versions)).group(1)
    else:
        return 'VERSION_NOT_FOUND'


setup(
        name="Indomnify", 
        description='Pythonic wrapper for Hyper Estraier',
        author='Decipher, Inc.',
        author_email='cory@decipherinc.com',
        maintainer='Cory Dodt',
        maintainer_email='cory@decipherinc.com',
        url='http://code.google.com/p/indomnify/',
        download_url='http://code.google.com/p/indomnify/downloads/list',
        version=versionFromReleaseNotes(),
        zip_safe=False,
        packages=find_packages(),

        install_requires=[
            'Distribute>=0.6.14',
            ],

        classifiers=[
          'Development Status :: 4 - Beta',
          'Environment :: Console',
          'Environment :: Web Environment',
          'Intended Audience :: Developers',
          'License :: OSI Approved :: MIT License',
          'Operating System :: POSIX',
          'Programming Language :: Python',
          'Programming Language :: JavaScript',
          'Topic :: Software Development :: Testing',
          ],
      )
